﻿using System;

namespace SewerAPI.Core
{
    /// <summary>
    /// Attribute to indicate that a property can be exported
    /// for serialization
    /// </summary>
    [AttributeUsage(AttributeTargets.Property,Inherited=true,AllowMultiple=false)]
    public class MessageExportAttribute : System.Attribute
    {
        private string name = string.Empty;
        public bool typehint = false;
        
        /// <summary>
        /// The export name
        /// </summary>
        public string Name
        {
            get { return name.ToLowerInvariant(); }
            set { name = value; }
        }

        /// <summary>
        /// Check if this attribute has a name value
        /// </summary>
        public bool HasValue
        {
            get { return !string.IsNullOrEmpty(Name); }
        }

        /// <summary>
        /// Indicates that this property is a type hint
        /// </summary>
        public bool IsTypeHint
        {
            get { return typehint; }
            set { typehint = value; }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name"></param>
        public MessageExportAttribute(string name)
        {
            if(!string.IsNullOrEmpty(name))
                this.Name = name;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        public MessageExportAttribute() : this(string.Empty) { }
    }
}
